package SyntaxTree;

import java.util.*;
public  class TokenCounter {
	private List<String> TokenVector;  // store the token stream 
	private List<Integer> CounterVector; // store the counter of each token 
	private int tokenvectorsize;
	
	public List<String> getTokenVector() {
		return TokenVector;
	}
	public void setTokenVector(List<String> tokenVector) {
		TokenVector = tokenVector;
	}
	public List<Integer> getCounterVector() {
		return CounterVector;
	}
	public void setCounterVector(List<Integer> counterVector) {
		CounterVector = counterVector;
	}
	public TokenCounter()
	{
		this.TokenVector = new ArrayList<String>();
		this.CounterVector = new ArrayList<Integer>();
		this.tokenvectorsize = 0;
	}
	public int GetSize(){
		return this.tokenvectorsize;
	}
	public void InsertToken(String token){
		this.TokenVector.add(token);
		this.CounterVector.add(1);
		this.tokenvectorsize = TokenVector.size();
		
	}
	/*
	 * find the token if is new we will get the size of the vetor
	 */
	public int FindToken(String token){
		int pos = TokenVector.size();
		for(int i=0;i<pos;i++){
			if(TokenVector.get(i).equals(token))
				pos = i ;
		}
		return pos;
	}
	public void AddCounter(int pos){
		int old = this.CounterVector.get(pos);
		old = old + 1 ;
		this.CounterVector.set(pos, old);
	}
	public void PrintToken(){
		for(int i = 0;i<TokenVector.size();i++){
			System.out.println(TokenVector.get(i));
			System.out.println(CounterVector.get(i));
		}
	}
	public boolean CheckToken(int kind){
		boolean flag = false;
		if(kind < 32 && kind > 7)
			flag = true;
		if(kind == 34)
			flag = true;
		return flag;
	}
}
